﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace MVCWeb
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(

                "logoff",
                "Logoff",
                new { controller = "Account", Action = "LogOff" }
            );



            routes.MapRoute(

                "orderdefault",
                "MyAccount/{custid}/{controller}/{action}",
                new { controller = "Order", action = "Index", custid = UrlParameter.Optional }
            );


            routes.MapRoute(

                "hmm..",
                "MyAccount/{custid}/{controller}/{action}",
                new { custid = UrlParameter.Optional }
            );

            routes.MapRoute(

                "webmaster",
                "MyAccount/{custid}/WebMaster/{controller}/{action}",
                new { custid = UrlParameter.Optional }
            );


            routes.MapRoute(
                "AccountHome",
                "MyAccount/{custid}",
                new
                {
                    controller = "Home",
                    action = "Index",
                    custid = UrlParameter.Optional
                }
              ); 

            routes.MapRoute(
                "Account",
                "MyAccount/{custid}",
                new
                {
                    controller = "Home",
                    action = "Account",
                    custid = UrlParameter.Optional
                }
              ); 

            routes.MapRoute(
                "Login",
                "login/{id}",
                new { controller = "Account", action = "LogOn", id = UrlParameter.Optional}

                );

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
               // new { controller = "Account", action = "LogOn", id = 0 } // Parameter defaults
                 new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );


        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);
            SearchRoutes(RouteTable.Routes);
        }

        public static void SearchRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Search", // Route name
                "{controller}/{action}/{display}/{make}/{size}/{res}/{refresh}/{shipping}", // URL with parameters
                new { controller = "Tv", action = "Search", display = 0, make = 0, size = 0, res = 0, refresh = 0, shipping = 0 } // Parameter defaults
            );

        }
    }
}